package cn.mg.framework.response;

import lombok.ToString;

/**
 * 错误码枚举
 *
 * @author hezhaoming
 * @date 2019-10-31
 */
@ToString
public enum CommonCode implements ResponseCode {
    /**
     * 操作成功
     */
    SUCCESS(true, "00000", "操作成功！"),
    /**
     * 用户端错误
     * 一级宏观错误码
     */
    USER_ERROR(false, "A0001", "用户端错误！"),
    /**
     * 二级宏观错误码
     */
    USER_SIGN_IN_ERROR_A0100(false, "A0100", "用户注册错误！"),
    USER_SIGN_IN_ERROR_A0101(false, "A0101", "用户未同意隐私协议！"),
    USER_SIGN_IN_ERROR_A0102(false, "A0102", "注册国家或地区受限！"),

    USER_SIGN_IN_ERROR_A0110(false, "A0110", "用户名校验失败！"),
    USER_SIGN_IN_ERROR_A0111(false, "A0111", "用户名已存在！"),
    USER_SIGN_IN_ERROR_A0112(false, "A0112", "用户名包含敏感词！"),
    USER_SIGN_IN_ERROR_A0113(false, "A0113", "用户名包含特殊字符！"),

    USER_SIGN_IN_ERROR_A0120(false, "A0120", "密码校验失败！"),
    USER_SIGN_IN_ERROR_A0121(false, "A0121", "密码长度不够！"),
    USER_SIGN_IN_ERROR_A0122(false, "A0122", "密码强度不够！"),

    USER_SIGN_IN_ERROR_A0130(false, "A0130", "校验码输入错误！"),
    USER_SIGN_IN_ERROR_A0131(false, "A0131", "短信校验码输入错误！"),
    USER_SIGN_IN_ERROR_A0132(false, "A0132", "邮件校验码输入错误！"),
    USER_SIGN_IN_ERROR_A0133(false, "A0133", "语音校验码输入错误！"),

    USER_SIGN_IN_ERROR_A0140(false, "A0140", "用户证件异常！"),
    USER_SIGN_IN_ERROR_A0141(false, "A0141", "用户证件类型未选择！"),
    USER_SIGN_IN_ERROR_A0142(false, "A0142", "大陆身份证编号校验非法！"),
    USER_SIGN_IN_ERROR_A0143(false, "A0143", "护照编号校验非法！"),
    USER_SIGN_IN_ERROR_A0144(false, "A0144", "军官证编号校验非法！"),

    USER_SIGN_IN_ERROR_A0150(false, "A0150", "用户基本信息校验失败！"),
    USER_SIGN_IN_ERROR_A0151(false, "A0151", "手机格式校验失败！"),
    USER_SIGN_IN_ERROR_A0152(false, "A0152", "地址格式校验失败！"),
    USER_SIGN_IN_ERROR_A0153(false, "A0153", "邮箱格式校验失败！"),

    //todo：后面自行扩展（参照泰山版规范手册）

    /**
     * 服务端错误
     */
    SERVER_ERROR(false, "B0001", "系统执行出错！"),

    SERVER_ERROR_B0100(false, "B0100", "系统执行超时！"),
    SERVER_ERROR_B0101(false, "B0101", "系统订单处理超时！"),

    SERVER_ERROR_B0200(false, "B0200", "系统容灾功能被触发！"),
    SERVER_ERROR_B0210(false, "B0210", "系统限流！"),
    SERVER_ERROR_B0220(false, "B0220", "系统功能降级！"),

    SERVER_ERROR_B0300(false, "B0300", "系统资源异常！"),
    SERVER_ERROR_B0310(false, "B0310", "系统资源耗尽！"),
    SERVER_ERROR_B0311(false, "B0311", "系统磁盘空间耗尽！"),
    SERVER_ERROR_B0312(false, "B0312", "系统内存耗尽！"),
    SERVER_ERROR_B0313(false, "B0313", "文件句柄耗尽！"),
    SERVER_ERROR_B0314(false, "B0314", "系统连接池耗尽！"),
    SERVER_ERROR_B0315(false, "B0315", "系统线程池耗尽！"),

    SERVER_ERROR_B0320(false, "B0320", "系统资源访问异常！"),
    SERVER_ERROR_B0321(false, "B0321", "系统读取磁盘文件失败！"),


    /**
     * 调用第三方服务出错
     */
    VENDOR_SERVER_ERROR(false, "C0001", "调用第三方服务出错！"),

    VENDOR_SERVER_ERROR_C0100(false, "C0100", "中间件服务出错！"),

    VENDOR_SERVER_ERROR_C0110(false, "C0110", " RPC 服务出错！"),
    VENDOR_SERVER_ERROR_C0111(false, "C0111", " RPC 服务未找到！"),
    VENDOR_SERVER_ERROR_C0112(false, "C0112", " RPC 服务未注册！"),
    VENDOR_SERVER_ERROR_C0113(false, "C0112", " 接口不存在！"),

    VENDOR_SERVER_ERROR_C0120(false, "C0120", "消息服务出错！"),
    VENDOR_SERVER_ERROR_C0121(false, "C0121", "消息投递出错！"),
    VENDOR_SERVER_ERROR_C0122(false, "C0122", "消息消费出错！"),
    VENDOR_SERVER_ERROR_C0123(false, "C0123", "消息订阅出错！"),
    VENDOR_SERVER_ERROR_C0124(false, "C0124", "消息分组未查到！"),


    VENDOR_SERVER_ERROR_C0130(false, "C0130", "缓存服务出错！"),
    VENDOR_SERVER_ERROR_C0131(false, "C0131", "key 长度超过限制！"),
    VENDOR_SERVER_ERROR_C0132(false, "C0132", "value 长度超过限制！"),
    VENDOR_SERVER_ERROR_C0133(false, "C0133", "存储容量已满！"),
    VENDOR_SERVER_ERROR_C0134(false, "C0134", "不支持的数据格式！"),

    VENDOR_SERVER_ERROR_C0140(false, "C0140", "配置服务出错！"),

    VENDOR_SERVER_ERROR_C0150(false, "C0150", "网络资源服务出错！"),
    VENDOR_SERVER_ERROR_C0151(false, "C0151", "VPN 服务出错！"),
    VENDOR_SERVER_ERROR_C0152(false, "C0152", "CDN 服务出错！"),
    VENDOR_SERVER_ERROR_C0153(false, "C0153", "域名解析服务出错！"),
    VENDOR_SERVER_ERROR_C0154(false, "C0154", "网关服务出错！"),

    VENDOR_SERVER_ERROR_C0200(false, "C0200", "第三方系统执行超时！"),
    VENDOR_SERVER_ERROR_C0210(false, "C0210", "RPC 执行超时！"),
    VENDOR_SERVER_ERROR_C0220(false, "C0220", "消息投递超时！"),
    VENDOR_SERVER_ERROR_C0230(false, "C0230", "缓存服务超时！"),
    VENDOR_SERVER_ERROR_C0240(false, "C0240", "配置服务超时！"),
    VENDOR_SERVER_ERROR_C0250(false, "C0250", "数据库服务超时！"),


    VENDOR_SERVER_ERROR_C0300(false, "C0300", "数据库服务出错！"),
    VENDOR_SERVER_ERROR_C0311(false, "C0311", "表不存在！"),
    VENDOR_SERVER_ERROR_C0312(false, "C0312", "列不存在！"),
    VENDOR_SERVER_ERROR_C0321(false, "C0321", "多表关联中存在多个相同名称的列！"),
    VENDOR_SERVER_ERROR_C0331(false, "C0331", "数据库死锁！"),
    VENDOR_SERVER_ERROR_C0341(false, "C0341", "主键冲突！"),

    VENDOR_SERVER_ERROR_C0400(false, "C0400", "第三方容灾系统被触发！"),
    VENDOR_SERVER_ERROR_C0401(false, "C0401", "第三方系统限流！"),
    VENDOR_SERVER_ERROR_C0402(false, "C0402", "第三方功能降级！"),

    VENDOR_SERVER_ERROR_C0500(false, "C0500", "通知服务出错！"),
    VENDOR_SERVER_ERROR_C0501(false, "C0501", "短信提醒服务失败！"),
    VENDOR_SERVER_ERROR_C0502(false, "C0502", "语音提醒服务失败！"),
    VENDOR_SERVER_ERROR_C0503(false, "C0503", "邮件提醒服务失败！");
    /**
     * 操作是否成功
     */
    boolean success;
    /**
     * 操作代码
     */
    String code;
    /**
     * 提示信息
     */
    String message;

    CommonCode(boolean success, String code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    @Override
    public boolean success() {
        return success;
    }

    @Override
    public String code() {
        return code;
    }

    @Override
    public String message() {
        return message;
    }


}
